package locality;


import static org.junit.Assert.*;

import java.util.ArrayList;

import genome.*;

import mantel.mantelTest;

import org.junit.*;

import tool.Utility;

public class DMGTest {

	private distanceMapGenerator dmg;
	private double[] in = {0.0};
	private int size = 12;
	private CGP g1 = new CGP(in,size);
	//private IG g2 = new IG(size);
	private int samples = 1000;
	private ArrayList<double[][]> dmat;
	private int PROBLEM_CASE = 2;
	
	
	@Before
	public void setUp() throws Exception {
		dmg = new distanceMapGenerator(g1.generateSpace(samples),PROBLEM_CASE);
		System.out.println(dmg.genotypeToPhenotype);
		dmat = dmg.genDMatrix();
	}
	
	@Test
	public void checkDistanceMatrices(){
		
		double[][] G = dmat.get(0);
		double[][] P = dmat.get(1);
		Utility.printMat(G); System.out.println();
		Utility.printMat(P); System.out.println();
		assertTrue(dmat!=null); //test distance matrix not null
		
		
	}
	
	@Test
	public void testCorrelogram(){
		System.out.println("Space size: "+dmat.get(0).length);
		double[][] G = dmat.get(0);
		double[][] P = dmat.get(1);
		double[][] cor = mantelTest.segmented_mantel_cor(G, P, 1000,9);
		mantelTest.printCorrelog(cor);
	}

}
